<?php
declare(strict_types=1);

namespace LowCode\UI;

use Closure;
use LowCode\Block;

/**
 * @method static static make(string $name = null, string $id = null);
 */
class FromSchema extends Node
{

    protected string $schemaId;

    /**
     * @param string|null $name 组件名称
     * @param string|null $id 组件ID
     */
    public function __construct(string $name = null, string $id = null)
    {
        parent::__construct($name);
        $this->schemaId = $id?:autoId("from-schema");
        $this->fromSchema($this->schemaId);
    }

    public function register($blockId, Closure $block): static
    {
        return $this->addBlock($blockId, Block::make("FromSchema",$block)->id($this->schemaId));
    }
}
